package tool.plot

import implicits.Implicits._
import shared.Pojo._
import tool.Pojo._
import tool.Tool
import tool.plot.AllPlot.RPlotB

import java.io.File

/**
 * Created by yz on 27/9/2020
 */
object CcaRda extends CcaRdaT with RPlotB {

  def producePlotConfigFile(data: AllPlotData, workspaceDir: File, extraData: ExtraDataData) = {
    Tool.dataCoverConfigFile(data, workspaceDir, configFileName, configJsonFileName)
    Tool.produceSampleColorFile(workspaceDir, data.color.colors)
  }

  override def getCommand(data:AllPlotData,extraData: ExtraDataData): String = {
    s"""
       |${Tool.rScript} ${new File(Tool.rPath, "rda_cca_plot.R").unixPath} --pc ${configFileName}
       |convert  -density 300 rdacca.pdf  rdacca.png
       |""".stripMargin
  }

  override def defaultPlotArg(tmpPlotData: AllPlotData): AllPlotData = {
    tmpPlotData.copy(
      layout = tmpPlotData.layout.copy(
        width = "10",
        height = "10",
        ox = "0",
        oy = "0",
        pointSize = "4",
        showEnv = "T",
        showSpecies = "T",
        speciesPointSize = "4"
      ),
      x = "1",
      y = "2",
      showSample = "T",
      showEllipse = "T",
      xFont = "10",
      xTitleFont = "12",
      yFont = "9",
      yTitleFont = "11",
      mainTitle = "",
      mainTitleFont = "8",
      legendFont = "8",
      legendTitle = "",
      legendTitleFont = "11",
      color = tmpPlotData.color.copy(
        envNameColor = "#E41A1C",
        envLineColor = "#E41A1C",
        speciesColor = "#FF8C00"
      ),
      font = tmpPlotData.font.copy(
        sampleFont = "7",
        envFont = "7",
        speciesFont = "7"
      )
    )
  }

}

